package demo.InterfaceDamo;

/**
 * 打印全部学生信息，打印全部学生平均分。
 * <p>
 * Version: 1.0
 * Author: 瓶子
 */
public class StudentsDateInterImpl1 implements StudentDateInter {
    private final Student[] students;  //成员变量，记录学生信息

    public StudentsDateInterImpl1( Student[] students ) {
        this.students = students;
    }

    @Override
    public void printAllStudentsInfos() {
        for ( int i = 0; i < students.length; i++ ) {
            Student student = students[i];
            System.out.println("学生姓名：" + student.getName() +
                                       "  学生性别：" + student.getSex() +
                                       "  学生成绩：" + student.getScore());
        }

    }

    @Override
    public void printAverageScore() {
        double sumscore = 0;
        for ( int i = 0; i < students.length; i++ ) {
            sumscore += students[i].getScore();
        }
        System.out.println("学生平均分为：" + sumscore / students.length);
    }
}
